package com.hutianao.gqgl.log.service.impl;

import com.hutianao.gqgl.log.respository.LogDao;
import com.hutianao.gqgl.log.service.LogService;
import com.hutianao.gqgl.login.entity.MenuLevelEntity;
import com.hutianao.gqgl.mybatis.entity.LogEntity;
import com.hutianao.gqgl.mybatis.entity.PtMenuEntity;
import com.hutianao.gqgl.mybatis.flexigrid.PaddingEntity;
import com.hutianao.gqgl.mybatis.flexigrid.PadingRstType;
import com.hutianao.gqgl.mybatis.ztree.ZtreeEntity;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


@Service("LogService")
public class    LogServiceImpl implements LogService {
    private static final Integer MENU_FIRST =1 ;
    @Resource
    private LogDao logDao;




    @Override
    public void deletelogInfoById(String ids) throws UncategorizedSQLException {
        logDao.deletelogInfoById(ids);
    }

    @Override
    public List<LogEntity> querylogListByName(String username) {

        return null;
    }



    @Override
    public PadingRstType<LogEntity> querylogInfoListByPage(LogEntity entity, PaddingEntity paddingEntity) {
        paddingEntity.deal(LogEntity.class);
        PadingRstType<LogEntity> padingRstType = new PadingRstType<>();
        padingRstType.setPage(paddingEntity.getPage());
        List<LogEntity> list = logDao.queryLogInfoListByPage(entity,paddingEntity);
        padingRstType.setRawRecords(list);
        Integer total = logDao.queryLogInfoTotal(entity);
        padingRstType.setTotal(total);
        padingRstType.putItems();
        return padingRstType;
    }





    @Override
    public void saveLog(LogEntity entity) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(new Date());

        entity.setCreatetime(format);
        logDao.insertSaveLog(entity);
    }

}
